let ak = ""
let title_name = "超有幸福"

// 测试
// let SDKAPPID = 1400467404;
// let SECRETKEY = '33fcc053153451adf0a0141dd7cd660e57e7daacaa6bc1481bb42dea43eba75b';
// let ht_api = 'https://cyxfht.xfyh4k5.com';
// let network = 'https://xfjz.xfyh4k5.com/app/index.php';
// let apis_network = 'http://192.168.0.148:81';
// let tcptApi = "xfjz.xfyh4k5.com"

//深圳配置
let SDKAPPID = 1400467404;
let SECRETKEY = '33fcc053153451adf0a0141dd7cd660e57e7daacaa6bc1481bb42dea43eba75b';
let ht_api = 'https://cyxfht.xfyh4k5.com';
let network = 'https://xfjz.xfyh4k5.com/app/index.php';
let apis_network = 'https://cyxfsj.xfyh4k5.com';
let tcptApi = "xfjz.xfyh4k5.com"
ak = "1Hm9KimqpgGIwGlxIfGmG22DgrnmKZL7"
title_name = "超有幸福"

//中数家政
// let SDKAPPID = 1400467404;
// let SECRETKEY = '33fcc053153451adf0a0141dd7cd660e57e7daacaa6bc1481bb42dea43eba75b';
// let ht_api = 'https://zsht.xfyh4k5.com';
// let network = 'https://zsjz.xfyh4k5.com/app/index.php';
// let apis_network = 'https://zsapi.xfyh4k5.com';
// let tcptApi = "zsjz.xfyh4k5.com"
// ak = "g0VcLhmotXhUwXTHub6EzyiKICGzU4G2"
// title_name = "中数家政"

// 爱道家服
// let SDKAPPID = 1400467404;
// let SECRETKEY = '33fcc053153451adf0a0141dd7cd660e57e7daacaa6bc1481bb42dea43eba75b';
// let ht_api = 'https://byht.cnaidao.top';
// let network = 'https://wxapp.cnaidao.top/app/index.php';
// let apis_network = 'https://hyapi.cnaidao.top';
// let tcptApi = "wxapp.cnaidao.top"
// ak = "p0ZX6AyinxG2rlvR6Z4Zul6nKH3ftXAM"
// title_name = "爱道家服"


// 上海配置
// let SDKAPPID = 1400756801;
// let SECRETKEY = "d1895e14aa6d65b7b52a195ee9c5a964c9b396e7d610576fcf699d221e97e79e";
// let ht_api = 'https://backstage.cyxf-sh.com';
// let network = 'https://applet.cyxf-sh.com/app/index.php';
// let apis_network = 'https://appapi.cyxf-sh.com';
// let tcptApi = "applet.cyxf-sh.com"

// 广东配置
// let SDKAPPID = 1400467404;
// let SECRETKEY = '33fcc053153451adf0a0141dd7cd660e57e7daacaa6bc1481bb42dea43eba75b';
// let ht_api = 'https://gd-cyxfht.xfyh4k5.com';
// let network = 'https://gd-xcx.xfyh4k5.com/app/index.php';
// let apis_network = 'https://gd-cyxf.xfyh4k5.com';
// let tcptApi = "gd-xcx.xfyh4k5.com"


let Intranetnet_bx = 'https://jzbx.xfyh4k5.com/'; //保险and答题正式

const baseurl = network;

import md5 from "./md5"
let secret = 'ef4906b73a7bf35b5c586257fe732cd9';



const request = (obj, type, is_ht = false) => {
	let time = new Date().getTime();
	let paskey = wx.getStorageSync('userInfo').paskey
	let sign = md5(secret + time + paskey)
	return new Promise((reslove, reject) => {
		wx.showLoading({
			title: '加载中',
			mask: true
		})
		console.log((!is_ht ? baseurl : ht_api) + (obj.url ? obj.url : ''))
		wx.request({
			url: (!is_ht ? baseurl : ht_api) + (obj.url ? obj.url : ''),
			data: {
				i: 5,
				from: "wxapp",
				c: "entry",
				a: "wxapp",
				m: "zh_cjdianc",
				apptype:getApp().globalData.apptype,
				paskey,
				time,
				sign,
				...obj.data
			},
			method: type,
			header: obj.header ? {
				"Content-Type": "application/json"
			} : {
				"Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
			},
			success(res) {
				wx.hideLoading();
				reslove(res)
			},
			fail(err) {
				wx.hideLoading();
				console.log('--err--')
				wx.showToast({
					title: "请求超时，请稍后重试",
					icon: "none"
				})
				reject(err)
			},
			complete: () => {
				return
				console.debug("接口-----------------------------------")
				console.debug(baseurl + (obj.url ? obj.url : ''))
				console.debug("参数-----------------------------------")
				console.debug(obj.data)
			}
		})
	})
}



const get = (obj, is_ht = false) => {
	return request(obj, 'GET', is_ht)
}
const post = (obj, is_ht = false) => {
	return request(obj, 'POST', is_ht)
}

module.exports = {
	SDKAPPID,
	SECRETKEY,
	post,
	get,
	baseurl,
	network,
	Intranetnet_bx,
	tcptApi,
	ht_api,
  apis_network,
  ak,
  title_name
}